﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UvsChess;
namespace StudentAI
{
    class Node
    {
        public Node parent;
        public ChessBoard currBoard;
        public ChessMove move;
        public ChessColor color;
        public int depth;
        public int? score;
        public Node(Node _parent, ChessBoard _currBoard, ChessMove _move, ChessColor _color, int _depth, int? _score = null)
        {
            parent = _parent;
            currBoard = _currBoard;
            move = _move;
            color = _color;
            depth = _depth;
            score = _score;
        }
        public bool betterThanParentScore(int? newScore, ChessColor myColor)
        {

            //black = negative
            //white = positive
            ChessColor currNodesColor = color;
            ChessColor parentNodesColor = parent.color;

            if(parent.score == null)
                return true;
            //check for min
            if (currNodesColor != myColor)
            {
                if (newScore < parent.score)
                    return true;
                else
                    return false;
            }//want to lowest score
            else
            {
                if (newScore > parent.score)
                    return true;
                else
                    return false;
            }//want highest score
        }
    }
}
